package com.scsj.supermarket.adapter.homeadapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.scsj.supermarket.R;
import com.scsj.supermarket.bean.homebean.HomeRecommendBean;

import java.util.List;

/**
 * 首页推荐
 */
public class HomeRecommendAdapter extends BaseQuickAdapter<HomeRecommendBean,BaseViewHolder> {

    private int type;

    public HomeRecommendAdapter(List data,int type) {
        super(R.layout.item_home_recommend_layout,data);
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, HomeRecommendBean item) {
        Glide.with(mContext).load(item.getIcon()).into((ImageView) helper.getView(R.id.home_icon_iv));
        helper.setText(R.id.home_address_tv,item.getAdress());
        helper.setText(R.id.home_recommend_name_tv,item.getName());
        helper.setText(R.id.home_recommend_price_tv,"¥"+item.getPrice());
        helper.setText(R.id.home_recommend_oldprice_tv,"¥"+item.getOldprice());
        if (type ==1){
            helper.setVisible(R.id.price_ll,false);
            helper.setVisible(R.id.home_recommend_price_tv,false);
            helper.setVisible(R.id.home_recommend_oldprice_tv,false);
        }
    }
}
